<template>
  <div class="undertake-detail">
    <PageTemplate>
      <div slot="content">
        <TitleBack :title="title"></TitleBack>
        <!-- 基本信息 -->
        <PageEditCollapse :is-search="false" :default-collapse="true">
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 200px;">{{$t('cm.baseinfo')}}</div>
          </div>
          <div>
            <el-form
              :model="projectInfo"
              label-position="right"
              label-width="150px"
              class="page-edit-colllapse-form"
              ref="projectInfo"
            >
              <el-row>
                <el-col :span="8">
                  <el-form-item label="项目编码" prop="projectCode" required>
                    <span>{{projectInfo.projectCode}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="项目名称" prop="projectName" required>
                    <span>{{projectInfo.projectName}}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="客户名称" prop="marketCustomerName">
                    <span>{{projectInfo.marketCustomerName}}</span>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="市场机会" prop="marketInfoName" v-if="projectInfo.marketInfoName">
                      <span>{{projectInfo.marketInfoName}}</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </div>
        </PageEditCollapse>
        <!-- 组建承揽团队 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[1]">
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">组建承揽团队</div>
          </div>
          <BlockLookEditToggle 
            ref="ptBlockToggle"
            :isDefaultActive="curEditIndex==1"
            v-loading="projectTeamLoading"
            :activeMouse="type==='edit'"
            @editClick="projectTeamEditClick"
            @mouseleave="projectTeamMouseleaveHandle"
            @cancelClick="projectTeamCancelClick"
            @saveClick="projectTeamSaveClick">
            <div slot="content">
              <el-form
                :model="projectTeam"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectTeam">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="是否跨专业" prop="ismultidisciplinary"  :rules="rules">
                      <span v-if="!projectTeamEdit">{{projectTeam.ismultidisciplinary == 1 ? '是' : '否'}}</span>
                      <el-select  v-else  v-model="projectTeam.ismultidisciplinary"  placeholder="请选择" >
                          <el-option label="是" :value="1"></el-option>
                          <el-option label="否" :value="0"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="承揽负责人" prop="leadingmanName"  :rules="rules">
                      <span v-if="!projectTeamEdit">{{projectTeam.leadingmanName}}</span>
                      <PersonSelect 
                        v-else
                        :value="projectTeam.leadingmanName" 
                        :multiple="false" 
                        ref="projectTeamLeadingman"
                        size="">
                      </PersonSelect>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                      <el-form-item label="承揽团队成员" prop="projectTeamMembersStr"  :rules="rules">
                      <span v-if="!projectTeamEdit">{{projectTeam.projectTeamMembersStr}}</span>
                      <PersonSelect 
                        v-else
                        :value="projectTeam.projectTeamMembersStr" 
                        v-bind:multiple="true" 
                        ref="projectTeamMembers"
                        size="">
                      </PersonSelect>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
        <!-- 项目评审 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[2]"
          >
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">项目评审</div>
          </div>
          <BlockLookEditToggle 
            ref="prBlockToggle"
            :isDefaultActive="(curEditIndex==2&&!undertakeDetail.projectReview)||(curEditIndex==2&&undertakeDetail.projectReview&&undertakeDetail.projectReview.reviewComments!=0)"
            v-loading="projectReviewLoading"
            :activeMouse="type==='edit'"
            @editClick="projectReviewEditClick"
            @mouseleave="projectReviewMouseleaveHandle"
            @cancelClick="projectReviewCancelClick"
            @saveClick="projectReviewSaveClick">
            <div slot="content">
              <el-form
                :model="projectReview"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectReview">
                <el-row>
                  <el-col :span='12'>
                      <el-form-item label="项目评审" prop="reviewNeed" :rules="rules">
                        <span v-if="!projectReviewEdit">{{projectReview.reviewNeed == 1 ? '需要' : '不需要'}}</span>
                        <div v-else>
                          <el-radio v-model="projectReview.reviewNeed" label="1">需要</el-radio>
                          <el-radio v-model="projectReview.reviewNeed" label="0">不需要</el-radio>
                        </div>
                     </el-form-item>
                   </el-col>
                </el-row>
                <div v-if="projectReview.reviewNeed == 1">
                  <el-row>
                    <el-col :span='12'>
                         <el-form-item label="评审日期" prop="reviewDate" :rules="rules">
                            <span v-if="!projectReviewEdit">{{projectReview.reviewDate}}</span>
                            <el-date-picker 
                              v-else
                              v-model="projectReview.reviewDate" 
                              type="date" 
                              value-format="yyyy-MM-dd"
                              placeholder="选择日期"
                              class="form-input">
                            </el-date-picker>
                          </el-form-item>
                     </el-col>
                     <el-col :span='12'>
                         <el-form-item label="评审地点" prop="reviewAdress" :rules="rules">
                            <span v-if="!projectReviewEdit">{{projectReview.reviewAdress}}</span>
                            <el-input class="form-input" v-else v-model="projectReview.reviewAdress"></el-input>
                         </el-form-item>
                     </el-col>
                     <el-col :span='12'>
                         <el-form-item label="评审人员" prop="projectReviewMembersStr" :rules="rules">
                            <span v-if="!projectReviewEdit">{{projectReview.projectReviewMembersStr}}</span>
                            <PersonSelect 
                              v-else
                              :value="projectReview.projectReviewMembersStr" 
                              v-bind:multiple="true" 
                              ref="projectReviewMembers"
                              size="">
                            </PersonSelect>
                         </el-form-item>
                     </el-col>
                   </el-row>
                   <el-row>
                      <el-col :span='10'>
                          <el-form-item label="结果评审" prop="reviewComments" :rules="rules">
                            <span v-if="!projectReviewEdit">{{projectReview.reviewComments == 1 ? '通过' : projectReview.reviewComments == 2 ? '有条件通过' : '不通过'}}</span>
                            <div v-else>
                              <el-radio v-model="projectReview.reviewComments" :label="1">通过</el-radio>
                              <el-radio v-model="projectReview.reviewComments" :label="2">有条件通过</el-radio>
                              <el-radio v-model="projectReview.reviewComments" :label="0">不通过</el-radio>
                            </div>
                        </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                      <el-col :span='20'>
                          <el-form-item label="评审意见" prop="reviewCommentsNote">
                            <span v-if="!projectReviewEdit">{{projectReview.reviewCommentsNote}}</span>
                            <el-input v-else v-model="projectReview.reviewCommentsNote" type="textarea" :rows="3"></el-input>
                        </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                     <el-col :span='12'>
                        <el-form-item label="评审材料" prop="reviewDataFileid" :rules="rules">
                          <span v-if="!projectReviewEdit">{{projectReview.reviewDataFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="reviewDataFileid"
                            :fileList="projectReviewReviewDataFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="会议纪要" prop="meetingMinutes" :rules="rules">
                          <span v-if="!projectReviewEdit">{{projectReview.meetingMinutesFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="meetingMinutes"
                            :fileList="projectReviewMeetingMinutesFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                  </el-row>
                </div>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
         <!-- 承揽阶段WBS及预算申请 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[3]"
          >
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">承揽阶段WBS及预算申请</div>
          </div>
          <BlockLookEditToggle 
            ref="wbsBlockToggle"
            :isDefaultActive="curEditIndex==3"
            v-loading="projectWbsLoading"
            :activeMouse="type==='edit'"
            @editClick="projectWbsEditClick"
            @mouseleave="projectWbsMouseleaveHandle"
            @cancelClick="projectWbsCancelClick"
            @saveClick="projectWbsSaveClick">
            <div slot="content">
              <el-form
                :model="projectWbs"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectWbs">
                <el-row>
                  <el-col :span='8'>
                      <el-form-item label="承揽预算申请" prop="cbsNeed" :rules="rules">
                        <span v-if="!projectWbsEdit">{{projectWbs.cbsNeed == 1 ? '需要' : '不需要'}}</span>
                        <div v-else>
                          <el-radio v-model="projectWbs.cbsNeed" label="1">需要</el-radio>
                          <el-radio v-model="projectWbs.cbsNeed" label="0">不需要</el-radio>
                        </div>
                     </el-form-item>
                   </el-col>
                </el-row>
                <div v-if="projectWbs.cbsNeed == 1">
                  <el-row>
                     <el-col :span='12'>
                         <el-form-item label="CBS编码" prop="cbsCode" :rules="rules">
                            <span v-if="!projectWbsEdit">{{projectWbs.cbsCode}}</span>
                            <el-input v-else v-model="projectWbs.cbsCode"></el-input>
                         </el-form-item>
                     </el-col>
                     <el-col :span='12'>
                         <el-form-item label="CSB名称" prop="cbsName" :rules="rules">
                            <span v-if="!projectWbsEdit">{{projectWbs.cbsName}}</span>
                            <el-input v-else v-model="projectWbs.cbsName"></el-input>
                         </el-form-item>
                     </el-col>
                     <el-col :span='12'>
                         <el-form-item label="负责人" prop="leadingman" :rules="rules">
                            <span v-if="!projectWbsEdit">{{projectWbs.leadingmanName}}</span>
                            <PersonSelect 
                              v-else
                              :value="projectWbs.leadingmanName" 
                              v-bind:multiple="false" 
                              ref="projectWbsLeadingman"
                              size="">
                            </PersonSelect>
                         </el-form-item>
                     </el-col>
                      <el-col :span='12'>
                         <el-form-item label="预算总额" prop="depositAmount" :rules="priceRules">
                            <span v-if="!projectWbsEdit">{{projectWbs.depositAmount}}</span>
                            <el-input v-else v-model="projectWbs.depositAmount" type="number"></el-input>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                         <el-form-item label="币种" prop="currency">
                            <span v-if="!projectWbsEdit">{{projectWbs.currencyLabel}}</span>
                            <el-select 
                              v-else
                              v-model="projectWbs.currency"  
                              placeholder="请选择">
                              <el-option 
                                v-for="item in currencyMap"
                                :key="item.dictText"
                                :label="item.dictText" 
                                :value="item.dictKey+''">
                              </el-option>
                            </el-select>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                         <el-form-item label="预算类别" prop="budgetType">
                            <span v-if="!projectWbsEdit">{{projectWbs.budgetTypeLabel}}</span>
                            <el-select 
                              v-else
                              v-model="projectWbs.budgetType"  
                              placeholder="请选择">
                              <el-option 
                                v-for="item in budgetTypeMap"
                                :key="item.dictText"
                                :label="item.dictText" 
                                :value="item.dictKey">
                              </el-option>
                            </el-select>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                         <el-form-item label="跨类别转储" prop="transClassification">
                            <span v-if="!projectWbsEdit">{{projectWbs.transClassification == 1 ? '是' : '否'}}</span>
                            <el-select  v-else v-model="projectWbs.transClassification"  placeholder="请选择" >
                              <el-option label="是" value="1"></el-option>
                              <el-option label="否" value="0"></el-option>
                            </el-select>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                         <el-form-item label="支付转储" prop="payStorage">
                            <span v-if="!projectWbsEdit">{{projectWbs.payStorage == 1 ? '是' : '否'}}</span>
                            <el-select  v-else v-model="projectWbs.payStorage"  placeholder="请选择" >
                              <el-option label="是" value="1"></el-option>
                              <el-option label="否" value="0"></el-option>
                            </el-select>
                         </el-form-item>
                      </el-col>
                     <el-col :span='12'>
                        <el-form-item label="WBS申请表" prop="wbssqFileid" :rules="rules">
                          <span v-if="!projectWbsEdit">{{projectWbs.wbssqFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="wbssqFileid"
                            :fileList="projectWbsWbssqFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="预算申请表" prop="yssqFileid" :rules="rules">
                          <span v-if="!projectWbsEdit">{{projectWbs.yssqFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="yssqFileid"
                            :fileList="projectWbsYssqFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                  </el-row>
                </div>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
        <!-- 主任室决策 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[4]"
          >
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">主任室决策</div>
          </div>
          <BlockLookEditToggle 
            ref="pdmBlockToggle"
            :isDefaultActive="(curEditIndex==4&&!undertakeDetail.projectDirectorMaking)||(curEditIndex==4&&undertakeDetail.projectDirectorMaking&&undertakeDetail.projectDirectorMaking.reviewComments!=0)"
            v-loading="projectDirectorMakingLoading"
            :activeMouse="type==='edit'"
            @editClick="projectDirectorMakingEditClick"
            @mouseleave="projectDirectorMakingMouseleaveHandle"
            @cancelClick="projectDirectorMakingCancelClick"
            @saveClick="projectDirectorMakingSaveClick">
            <div slot="content">
              <el-form
                :model="projectDirectorMaking"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectDirectorMaking">
                <el-row>
                  <el-col :span='12'>
                      <el-form-item label="主任室决策" prop="directorMakeNeed" :rules="rules">
                        <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.directorMakeNeed == 1 ? '需要' : '不需要'}}</span>
                        <div v-else>
                          <el-radio v-model="projectDirectorMaking.directorMakeNeed" label="1">需要</el-radio>
                          <el-radio v-model="projectDirectorMaking.directorMakeNeed" label="0">不需要</el-radio>
                        </div>
                     </el-form-item>
                   </el-col>
                </el-row>
                <div v-if="projectDirectorMaking.directorMakeNeed == 1">
                  <el-row>
                    <el-col :span='12'>
                         <el-form-item label="评审日期" prop="reviewDate" :rules="rules">
                            <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.reviewDate}}</span>
                            <el-date-picker 
                              v-else
                              v-model="projectDirectorMaking.reviewDate" 
                              type="date" 
                              value-format="yyyy-MM-dd"
                              placeholder="选择日期">
                            </el-date-picker>
                          </el-form-item>
                     </el-col>
                     <el-col :span='12'>
                         <el-form-item label="评审地点" prop="reviewAdress" :rules="rules">
                            <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.reviewAdress}}</span>
                            <el-input v-else v-model="projectDirectorMaking.reviewAdress"></el-input>
                         </el-form-item>
                     </el-col>
                   </el-row>
                   <el-row>
                      <el-col :span='10'>
                          <el-form-item label="结果评审" prop="reviewComments" :rules="rules">
                            <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.reviewComments == 1 ? '通过' : projectDirectorMaking.reviewComments == 2 ? '有条件通过' : '不通过'}}</span>
                            <div v-else>
                              <el-radio v-model="projectDirectorMaking.reviewComments" :label="1">通过</el-radio>
                              <el-radio v-model="projectDirectorMaking.reviewComments" :label="2">有条件通过</el-radio>
                              <el-radio v-model="projectDirectorMaking.reviewComments" :label="0">不通过</el-radio>
                            </div>
                        </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                      <el-col :span='20'>
                          <el-form-item label="评审意见" prop="reviewCommentsNote">
                            <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.reviewCommentsNote}}</span>
                            <el-input v-else v-model="projectDirectorMaking.reviewCommentsNote" type="textarea" :rows="3"></el-input>
                        </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                     <el-col :span='12'>
                        <el-form-item label="汇报材料" prop="reportDataFileid" :rules="rules">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.reportDataFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="reportDataFileid"
                            :fileList="projectDirectorMakingReportDataFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="决策会议审批表" prop="decisionmakingMeetingFileid" :rules="rules">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.decisionmakingMeetingFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="decisionmakingMeetingFileid"
                            :fileList="projectDirectorMakingDecisionmakingMeetingFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="未参会领导审议意见" prop="wchldFileid">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.wchldFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="wchldFileid"
                            :fileList="projectDirectorMakingWchldFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                     <el-col :span='12'>
                        <el-form-item label="集体决策记录表" prop="jtjcjlFileid" :rules="rules">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.jtjcjlFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="jtjcjlFileid"
                            :fileList="projectDirectorMakingJtjcjlFileList">
                            :limit="1"
                           </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="集体决策会议纪要" prop="jtjchyjyFileid" :rules="rules">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.jtjchyjyFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="jtjchyjyFileid"
                            :fileList="projectDirectorMakingJtjchyjyFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="签到表" prop="signFileid">
                          <span v-if="!projectDirectorMakingEdit">{{projectDirectorMaking.signFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="signFileid"
                            :fileList="projectDirectorMakingSignFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                  </el-row>
                </div>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
         <!-- 投标报价 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[5]"
          >
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">投标报价</div>
          </div>
          <BlockLookEditToggle 
            ref="toBlockToggle"
            :isDefaultActive="curEditIndex==5"
            v-loading="projectTenderOfferLoading"
            :activeMouse="type==='edit'"
            @editClick="projectTenderOfferEditClick"
            @mouseleave="projectTenderOfferMouseleaveHandle"
            @cancelClick="projectTenderOfferCancelClick"
            @saveClick="projectTenderOfferSaveClick">
            <div slot="content">
              <el-form
                :model="projectTenderOffer"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectTenderOffer">
                <el-row>
                  <el-col :span='8'>
                      <el-form-item label="投标报价" prop="bjNeed" :rules="rules">
                        <span v-if="!projectTenderOfferEdit">{{projectTenderOffer.bjNeed == 1 ? '需要' : '不需要'}}</span>
                        <div v-else>
                          <el-radio v-model="projectTenderOffer.bjNeed" label="1">需要</el-radio>
                          <el-radio v-model="projectTenderOffer.bjNeed" label="0">不需要</el-radio>
                        </div>
                     </el-form-item>
                   </el-col>
                </el-row>
                <div v-if="projectTenderOffer.bjNeed == 1">
                   <el-row>
                     <el-col :span='12'>
                        <el-form-item label="报价书" prop="bjsFileid" :rules="rules">
                          <span v-if="!projectTenderOfferEdit">{{projectTenderOffer.bjsFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="bjsFileid"
                            :fileList="projectTenderOfferBjsFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="损益测算表" prop="sycsbFileid" :rules="rules">
                          <span v-if="!projectTenderOfferEdit">{{projectTenderOffer.sycsbFileName}}</span>
                          <FileUploadCommon 
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove" 
                            fileKey="sycsbFileid"
                            :fileList="projectTenderOfferSycsbFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                  </el-row>
                </div>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
         <!-- 合同推荐 -->
        <PageEditCollapse 
          :is-search="false" 
          :default-collapse="true"
          v-if="showModules[6]"
          >
          <div slot="title" class="page-edit-colllapse-title">
            <div style="width: 400px;">合同推荐</div>
          </div>
          <BlockLookEditToggle 
            ref="htBlockToggle"
            :isDefaultActive="curEditIndex==6"
            v-loading="projectHtLoading"
            :activeMouse="type==='edit'"
            @editClick="projectHtEditClick"
            @mouseleave="projectHtMouseleaveHandle"
            @cancelClick="projectHtCancelClick"
            @saveClick="projectHtSaveClick">
            <div slot="content">
              <el-form
                :model="projectHt"
                label-position="right"
                label-width="150px"
                class="page-edit-colllapse-form"
                ref="projectHt">
                   <el-row>
                      <el-col :span='12'>
                         <el-form-item label="合同编码" prop="contractCode" :rules="rules">
                            <span v-if="!projectHtEdit">{{projectHt.contractCode}}</span>
                            <el-input v-else v-model="projectHt.contractCode"></el-input>
                         </el-form-item>
                      </el-col>
                       <el-col :span='12'>
                         <el-form-item label="合同名称" prop="contractName" :rules="rules">
                            <span v-if="!projectHtEdit">{{projectHt.contractName}}</span>
                            <el-input v-else v-model="projectHt.contractName"></el-input>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                         <el-form-item label="重大关联交易" prop="iszuidaguanlian" :rules="rules">
                            <span v-if="!projectHtEdit">{{projectHt.iszuidaguanlian == 1 ? '是' : '否'}}</span>
                            <el-select  v-else  v-model="projectHt.iszuidaguanlian"  placeholder="请选择" >
                              <el-option label="是" :value="1"></el-option>
                              <el-option label="否" :value="0"></el-option>
                            </el-select>
                         </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                      <el-col :span='12'>
                         <el-form-item label="合同签约代表" prop="contractQjdb" :rules="rules">
                            <span v-if="!projectHtEdit">{{projectHt.contractQjdb}}</span>
                            <el-input v-else v-model="projectHt.contractQjdb"></el-input>
                         </el-form-item>
                      </el-col>
                       <el-col :span='12'>
                         <el-form-item label="合同初始价格" prop="contractCsjg" :rules="priceRules">
                            <span v-if="!projectHtEdit">{{projectHt.contractCsjg}}</span>
                            <el-input v-else v-model="projectHt.contractCsjg" type="number"></el-input>
                         </el-form-item>
                      </el-col>
                   </el-row>
                   <el-row>
                     <el-col :span='16'>
                         <el-form-item label="活动类型" prop="hdTypeChild" :rules="rules">
                            <span v-if="!projectHtEdit">{{projectHt.hdTypeLabel}}-{{projectHt.hdTypeChildLabel}}</span>
                            <div v-else class="double-select">
                              <el-select 
                                v-model="projectHt.hdType"  
                                placeholder="请选择">
                                <el-option 
                                  v-for="item in hdTypeMap"
                                  :key="item.dictText"
                                  :label="item.dictText" 
                                  :value="item.dictKey">
                                </el-option>
                              </el-select>
                              <el-select 
                                v-model="projectHt.hdTypeChild"  
                                placeholder="请选择">
                                <el-option 
                                  v-for="item in hdTypeChildMap"
                                  :key="item.dictText"
                                  :label="item.dictText" 
                                  :value="item.dictKey">
                                </el-option>
                              </el-select>
                            </div>
                         </el-form-item>
                      </el-col>
                      <el-col :span='12'>
                        <el-form-item label="合同文本" prop="contractFileid" :rules="rules">
                          <span v-if="!projectHtEdit">{{projectHt.contractFileName}}</span>
                          <FileUploadCommon  
                            v-else 
                            @uploadSuccess="uploadSuccess"
                            @uploadRemove="uploadRemove"
                            fileKey="contractFileid"
                            :fileList="projectHtContractFileList"
                            :limit="1">
                          </FileUploadCommon>
                        </el-form-item>
                      </el-col>
                  </el-row>
              </el-form>
            </div>
          </BlockLookEditToggle>
          <div>
          </div>
        </PageEditCollapse>
      </div>
    </PageTemplate>

  </div>
</template>

<script>
import { ALERT } from '@/utils/responseHandle'
import * as Constant from '@/utils/constant'
import PageTemplate from '@/components/common/PageTemplate'
import PageEditCollapse from '@/components/common/PageEditCollapse'
import TitleBack from '@/components/common/TitleBack'
import BlockLookEditToggle from '@/components/common/BlockLookEditToggle'
import HasBtn from '@/mixins/HasBtn'
import { mapState } from 'vuex'
import {COMMON} from '@/utils/commonUtil'
import opr_management from '@/api/opr_management'
import PersonSelect from '@/components/asc/PersonSelect'
import sys_manage from '@/api/sys_manage'
import FileUploadCommon from '@/components/common/FileUploadCommon'
export default {
  components: {
    PageTemplate, 
    PageEditCollapse, 
    TitleBack, 
    BlockLookEditToggle,
    PersonSelect,
    FileUploadCommon
  },
  props: {
    // look：查看；edit：编辑
    type: {
      type: String,
      default: "look"
    },
  },
  data () {
    return {
      title:"项目承揽详情",
      //当前默认显示为编辑状态的模块index
      curEditIndex:null,
      //接口返回的全部信息合集
      undertakeDetail:{},
      //模块是否显示
      showModules:[],
      //基本信息data
      projectInfo: {},
      //组建承揽团队data
      projectTeam: {},
      //项目评审data
      projectReview:{
        reviewNeed: '1',
        reviewComments: '1',
      },
      //承揽阶段WBS及预算申请data
      projectWbs:{
        cbsNeed: '1',
      },
      ///主任室决策data
      projectDirectorMaking:{
        directorMakeNeed: '1',
        reviewComments: '1',
      },
      //投标报价
      projectTenderOffer:{
        bjNeed: '1',
      },
      //合同推荐
      projectHt:{},

      rules:[{ required: true, message: '必填项',trigger: 'blur'}],
      priceRules:[{ required: true, message: '必填,且必须是数字',trigger: 'blur'}],
      // projectTeamRules:{
      //   ismultidisciplinary:[
      //     { required: true, message: '必填项',trigger: 'blur'}
      //   ],
      //   leadingmanName:[
      //     { required: true, message: '必填项',trigger: 'blur'}
      //   ],
      //   projectTeamMembersStr:[
      //     { required: true, message: '必填项',trigger: 'blur'}
      //   ]
      // },
      marketVisible: false,//市场机会弹窗
      
      leadingmanVisible: false,//承揽负责人弹窗
      membersVisible: false,//承揽团队成员弹窗
      projectTeamEdit:false,//组建承揽团队是否为编辑模式
      projectTeamLoading:false,//组建承揽团队loading
      
      reviewMembersVisible: false,//评审人员弹窗
      projectReviewEdit:false,//项目评审是否为编辑模式
      projectReviewLoading:false,//项目评审loading

      projectWbsLeadingmanVisible: false,//承揽阶段WBS及预算申请负责人弹窗
      projectWbsEdit:false,//承揽阶段WBS及预算申请是否为编辑模式
      projectWbsLoading:false,//承揽阶段WBS及预算申请loading

      projectDirectorMakingEdit:false,//主任室决策是否为编辑模式
      projectDirectorMakingLoading:false,//主任室决策loading

      projectTenderOfferEdit:false,//投标报价是否为编辑模式
      projectTenderOfferLoading:false,//投标报价loading
      
      projectHtEdit:false,//合同推荐是否为编辑模式
      projectHtLoading:false,//合同推荐loading

      hdTypeMap:[],//活动类型一字典
      hdTypeChildMap:[],////活动类型二字典
      currencyMap:[],//币种字典
      budgetTypeMap:[],//预算类别字典

      projectReviewReviewDataFileList:[],
      projectReviewMeetingMinutesFileList:[],
      projectWbsWbssqFileList:[],
      projectWbsYssqFileList:[],
      projectHtContractFileList:[],
      projectDirectorMakingReportDataFileList:[],
      projectDirectorMakingDecisionmakingMeetingFileList:[],
      projectDirectorMakingWchldFileList:[],
      projectDirectorMakingJtjcjlFileList:[],
      
      
    }
  },
  watch: {
    undertakeDetail:{
      handler:function(val){
        const { 
          projectInfo,
          projectTeam,
          projectReview,
          projectWbs,
          projectDirectorMaking,
          projectTenderOffer,
          projectHt
        } = val;
        let showProjectInfo = projectInfo ? true :false;
        let showProjectTeam = projectTeam ? true :false;
        let showProjectReview = projectReview&&projectReview.reviewComments !=0 ? true :false;
        let showProjectWbs = projectWbs ? true :false;
        let showProjectDirectorMaking = projectDirectorMaking&&projectDirectorMaking.reviewComments !=0 ? true :false;
        let showProjectTenderOffer = projectTenderOffer ? true :false;
        let showProjectHt = projectHt ? true : false ;
        let arr = [showProjectInfo,showProjectTeam,showProjectReview,showProjectWbs,showProjectDirectorMaking,showProjectTenderOffer,showProjectHt];
        this.showModules = this.showModulesFn(arr,this.type);
        switch(this.curEditIndex){
            case 1 :
              this.projectTeamEdit = true;
              break; 
            case 2 :
              if(!projectReview){
                this.projectReviewEdit = true;
              }else{
                 if(projectReview.reviewComments !=0){
                    this.projectReviewEdit = true;
                  }else{
                    // this.projectReviewEdit = false;
                    this.curEditIndex = null
                  }
              }
              break; 
            case 3 :
              this.projectWbsEdit = true;
              break; 
            case 4 :
               if(!projectDirectorMaking){
                 this.projectDirectorMakingEdit = true;
               }else{
                 if(projectDirectorMaking.reviewComments !=0){
                  this.projectDirectorMakingEdit = true;
                }else{
                  // this.projectDirectorMakingEdit = false;
                  this.curEditIndex = null
                }
               }
              break; 
            case 5 :
              this.projectTenderOfferEdit = true;
              break; 
            case 6 :
              this.projectHtEdit = true;
              break; 
        }
      },
      deep:true,
    }, 
    "projectHt.hdType"(newVal,oldVal) {
      this.sysDictLoadByPaging(newVal,(result)=>{
        this.hdTypeChildMap = result.data
        if(oldVal) this.projectHt.hdTypeChild = ''
       
      })
    },
     "projectTeam.members"(val) {
        if(val.length ==0 ) return;
        this.$set(this.projectTeam,'projectTeamMembersStr',COMMON.arrToStr(val,"peopleName"))
    }, 
     "projectReview.members"(val) {
        if(val.length ==0 ) return;
        this.$set(this.projectReview,'projectReviewMembersStr',COMMON.arrToStr(val,"peopleName"))
    }, 
  },
  computed: {
    //评审人员字符串
    // projectReviewMembersStr(){
    //   const { members } = this.projectReview
    //   return COMMON.arrToStr(members,"peopleName");
    // },
    
  },
  created () {
   
    //获取全部字典
    this.getAllMap()
    //获取详情
    this.getInitData();
  },
  methods: {
    //获取全部字典
    getAllMap(){
       //获取活动类型字典
      this.sysDictLoadByPaging("run_activity_type",(result)=>{
          this.hdTypeMap = result.data
      })
      //获取币种字典
      this.sysDictLoadByPaging("run_currency",(result)=>{
          this.currencyMap = result.data
      })
      //获取预算类别字典
      this.sysDictLoadByPaging("run_budget_type",(result)=>{
          this.budgetTypeMap = result.data
      })

    },
    //获取字典接口
    sysDictLoadByPaging (key,callback) { 
      sys_manage.sysDictLoadByPaging({dictGroupKey: key}, result => {
        if (result.code === Constant.RT_SUCCESS) {
          callback(result)
        } else {
          ALERT.error(result.msg)
        }
      })
    },

    uploadSuccess(res,fileKey){
      if (!(res.data && res.data[0])) return;
      let { fileId }= res.data[0];
      let file = {name: res.data[0].fileName, url: res.data[0].url, id: res.data[0].fileId}
       switch(fileKey){
        case 'reviewDataFileid'://项目评审-评审材料
          this.projectReview.reviewDataFileid = fileId
          this.projectReviewReviewDataFileList.push(file);
          break;
        case 'meetingMinutes':  //项目评审-会议纪要
          this.projectReview.meetingMinutes = fileId
          this.projectReviewMeetingMinutesFileList.push(file);
          break;
        case 'wbssqFileid':  //承揽阶段WBS及预算申请-WBS申请表
          this.projectWbs.wbssqFileid = fileId
          this.projectWbsWbssqFileList.push(file);
          
          break;
        case 'yssqFileid':  //承揽阶段WBS及预算申请-预算申请表
          this.projectWbs.yssqFileid = fileId
          this.projectWbsYssqFileList.push(file);
          break;
        case 'reportDataFileid':  //主任室决策-汇报材料
          this.projectDirectorMaking.reportDataFileid = fileId
          this.projectDirectorMakingReportDataFileList.push(file);
          break;
        case 'decisionmakingMeetingFileid':  //主任室决策-决策会议审批表
          this.projectDirectorMaking.decisionmakingMeetingFileid = fileId
          this.projectDirectorMakingDecisionmakingMeetingFileList.push(file);
          break;
        case 'wchldFileid':  //主任室决策-未参会领导审议意见
          this.projectDirectorMaking.wchldFileid = fileId
          this.projectDirectorMakingWchldFileList.push(file);
          break;
        case 'jtjcjlFileid':  //主任室决策-集体决策记录表
          this.projectDirectorMaking.jtjcjlFileid = fileId
          this.projectDirectorMakingJtjcjlFileList.push(file);
          break;
        case 'jtjchyjyFileid':  //主任室决策-集体决策会议纪要
          this.projectDirectorMaking.jtjchyjyFileid = fileId
          this.projectDirectorMakingJtjchyjyFileList.push(file);
          break;
        case 'signFileid':  //主任室决策-签到表
          this.projectDirectorMaking.signFileid = fileId
          this.projectDirectorMakingSignFileList.push(file);
          break;
        case 'bjsFileid':  //投标报价-报价书
          this.projectTenderOffer.bjsFileid = fileId
          this.projectDirectorMakingSignFileList.push(file);
          break;
        case 'sycsbFileid':  //投标报价-损益测算表
          this.projectTenderOffer.sycsbFileid = fileId
          this.projectDirectorMakingSignFileList.push(file);
          break;
        case 'contractFileid':  //合同推荐-合同文本
          this.projectHt.contractFileid = fileId
          this.projectHtContractFileList.push(file);
          break;
      } 
    },

    uploadRemove(fileList,fileKey){
        let resList = fileList.map(item => {
          return {
            name: item.name,
            url: item.url,
            id: item.fileId
          }
        })
        let fileId = resList.map(item=>item.id).join(",");
       switch(fileKey){
        case 'reviewDataFileid'://项目评审-评审材料
          this.projectReviewReviewDataFileList = resList;
          this.projectReview.reviewDataFileid = fileId;
          break;
        case 'meetingMinutes':  //项目评审-会议纪要
          this.projectReviewMeetingMinutesFileList = resList;
          this.projectReview.meetingMinutes = fileId;
          break;
        case 'wbssqFileid':  //承揽阶段WBS及预算申请-WBS申请表
          this.projectWbsWbssqFileList = resList;
          this.projectWbs.wbssqFileid = fileId
          break;
        case 'yssqFileid':  //承揽阶段WBS及预算申请-预算申请表
          this.projectWbsYssqFileList = resList;
          this.projectWbs.yssqFileid = fileId
          break;
        case 'reportDataFileid':  //主任室决策-汇报材料
          this.projectDirectorMakingReportDataFileList = resList;
          this.projectDirectorMaking.reportDataFileid = fileId
          break;
        case 'decisionmakingMeetingFileid':  //主任室决策-决策会议审批表
          this.projectDirectorMakingDecisionmakingMeetingFileList = resList;
          this.projectDirectorMaking.decisionmakingMeetingFileid = fileId
          break;
        case 'wchldFileid':  //主任室决策-未参会领导审议意见
          this.projectDirectorMakingWchldFileList = resList;
          this.projectDirectorMaking.wchldFileid = fileId
          break;
        case 'jtjcjlFileid':  //主任室决策-集体决策记录表
          this.projectDirectorMakingJtjcjlFileList = resList;
          this.projectDirectorMaking.jtjcjlFileid = fileId
          break;
        case 'jtjchyjyFileid':  //主任室决策-集体决策会议纪要
          this.projectDirectorMakingJtjchyjyFileList = resList;
          this.projectDirectorMaking.jtjchyjyFileid = fileId
          break;
        case 'signFileid':  //主任室决策-签到表
          this.projectDirectorMakingSignFileList = resList;
          this.projectDirectorMaking.signFileid = fileId
          break;
        case 'bjsFileid':  //投标报价-报价书
          this.projectDirectorMakingSignFileList = resList;
          this.projectTenderOffer.bjsFileid = fileId
          break;
        case 'sycsbFileid':  //投标报价-损益测算表
          this.projectDirectorMakingSignFileList = resList;
          this.projectTenderOffer.sycsbFileid = fileId
          break;
        case 'contractFileid':  //合同推荐-合同文本
          this.projectHtContractFileList = resList;
          this.projectHt.contractFileid = fileId
          break;
      } 
    },
    //获取详情
    getInitData(){
       opr_management.getProjectUndertakeInfoById({
         id:this.$router.history.current.params.id
       }, result => {
         if (result.code === Constant.RT_SUCCESS) {
            const { 
             projectInfo,
             projectTeam,
             projectReview,
             projectWbs,
             projectDirectorMaking,
             projectTenderOffer,
             projectHt
            } = result.data;
           this.undertakeDetail = JSON.parse(JSON.stringify(result.data));
           if(projectInfo)  this.projectInfo =  projectInfo;
           if(projectTeam)  this.projectTeam = projectTeam;
           if(projectReview)  this.projectReview =  projectReview;
           if(projectWbs)  this.projectWbs = projectWbs;
           if(projectDirectorMaking)  this.projectDirectorMaking =  projectDirectorMaking;
           if(projectTenderOffer)  this.projectTenderOffer = projectTenderOffer;
           if(projectHt)  this.projectHt = projectHt;
           //已有附件
            if(projectReview){//项目评审
              if(projectReview.reviewDataFileid){
                this.projectReviewReviewDataFileList =[
                  {
                    name:projectReview.reviewDataFileName,
                    id:projectReview.reviewDataFileid
                  }
                ]
              }
              if(projectReview.meetingMinutes){
                this.projectReviewMeetingMinutesFileList =[
                  {
                    name:projectReview.meetingMinutesFileName,
                    id:projectReview.meetingMinutes
                  }
                ]
              }
            }

            if(projectWbs){//承揽阶段WBS及预算申请
              if(projectWbs.wbssqFileid){
                this.projectWbsWbssqFileList =[
                  {
                    name:projectWbs.wbssqFileName,
                    id:projectWbs.wbssqFileid
                  }
                ]
              }
              if(projectWbs.yssqFileid){
                this.projectWbsYssqFileList =[
                  {
                    name:projectWbs.yssqFileName,
                    id:projectWbs.yssqFileid
                  }
                ]
              }
            }

            if(projectDirectorMaking){//主任室决策
              if(projectDirectorMaking.reportDataFileid){
                this.projectDirectorMakingReportDataFileList =[
                  {
                    name:projectDirectorMaking.reportDataFileName,
                    id:projectDirectorMaking.reportDataFileid
                  }
                ]
              }
              if(projectDirectorMaking.decisionmakingMeetingFileid){
                this.projectDirectorMakingDecisionmakingMeetingFileList =[
                  {
                    name:projectDirectorMaking.decisionmakingMeetingFileName,
                    id:projectDirectorMaking.decisionmakingMeetingFileid
                  }
                ]
              }
              if(projectDirectorMaking.wchldFileid){
                this.projectDirectorMakingWchldFileList =[
                  {
                    name:projectDirectorMaking.wchldFileName,
                    id:projectDirectorMaking.wchldFileid
                  }
                ]
              }
              if(projectDirectorMaking.jtjcjlFileid){
                this.projectDirectorMakingJtjcjlFileList =[
                  {
                    name:projectDirectorMaking.jtjcjlFileName,
                    id:projectDirectorMaking.jtjcjlFileid
                  }
                ]
              }
               if(projectDirectorMaking.jtjchyjyFileid){
                this.projectDirectorMakingJtjchyjyFileList =[
                  {
                    name:projectDirectorMaking.jtjchyjyFileName,
                    id:projectDirectorMaking.jtjchyjyFileid
                  }
                ]
              }
              if(projectDirectorMaking.signFileid){
                this.projectDirectorMakingSignFileList =[
                  {
                    name:projectDirectorMaking.signFileName,
                    id:projectDirectorMaking.signFileid
                  }
                ]
              }
            }

            if(projectTenderOffer){//投标报价
              if(projectTenderOffer.bjsFileid){
                this.projectTenderOfferBjsFileList =[
                  {
                    name:projectTenderOffer.bjsFileName,
                    id:projectTenderOffer.bjsFileid
                  }
                ]
              }
              if(projectTenderOffer.sycsbFileid){
                this.projectTenderOfferSycsbFileList =[
                  {
                    name:projectTenderOffer.sycsbFileName,
                    id:projectTenderOffer.sycsbFileid
                  }
                ]
              }
            }

            if(projectHt){//合同推荐
              if(projectHt.contractFileid){
                this.projectHtContractFileList =[
                  {
                    name:projectHt.contractFileName,
                    id:projectHt.contractFileid
                  }
                ]
              }
            }

           
        } else {
          ALERT.error(result.msg)
        }
        
      })

    },
    
    //判断模块是否显示
    showModulesFn(arr,type){
     let newArr =[];
     let flag = true; 
     for(let i = 0;i<arr.length;i++){
       let bol = true;
       let tmmpArr = arr.slice(0,i+1);
       for(let item of arr.slice(0,i+1)){
         if(bol==true&&!!item == false&&flag&&type=='edit'){
           bol = true;
           flag = false;
           this.curEditIndex = i;
         }else{
           bol = bol && item
         }
       }
       if(i == arr.length-1 && flag){
         this.curEditIndex = null;
       }
       newArr[i] = bol
     }
     return newArr
    },

    //取消所有编辑状态
    inactiveAll(refs){
      let refsArr =['ptBlockToggle','prBlockToggle','wbsBlockToggle','pdmBlockToggle','toBlockToggle','htBlockToggle'];
      refsArr.forEach(element => {
        if(refs!=element &&  this.$refs[element]) {
          this.$refs[element].cancelClick();
        }
      });
      this.curEditIndex = null;
    },


    //组建承揽团队编辑操作相关方法
    projectTeamEditClick(){
      this.inactiveAll("ptBlockToggle");
      this.projectTeamEdit = true;
    },
    projectTeamMouseleaveHandle({showBtn}){
      this.projectTeamEdit = showBtn;
    },
    projectTeamCancelClick(){
      this.projectTeamEdit = false;
      this.$refs.projectTeam.clearValidate();
      this.projectTeam = this.undertakeDetail.projectTeam ? JSON.parse(JSON.stringify(this.undertakeDetail.projectTeam)) : {}
    },
   
    //组建承揽团队保存
    projectTeamSaveClick(){
      this.projectTeam.members = COMMON.changePersonSelectData(this.$refs.projectTeamMembers);
      this.$set(this.projectTeam,'projectTeamMembersStr',COMMON.arrToStr(this.projectTeam.members,"peopleName"))
      this.$set(this.projectTeam,"leadingmanName",COMMON.changePersonSelectData(this.$refs.projectTeamLeadingman,false).peopleName)
      this.$set(this.projectTeam,"leadingman",COMMON.changePersonSelectData(this.$refs.projectTeamLeadingman,false).peopleNumber)
      this.$refs.projectTeam.validate((valid, error) => {
        if (valid) {
          this.projectTeamLoading = true;
          const {
            ismultidisciplinary,
            leadingman,
            leadingmanName,
            members
          } = this.projectTeam;
          opr_management.saveProjectUndertakeTeam({
            projectid:this.$router.history.current.params.id,
            ismultidisciplinary,
            leadingman,
            leadingmanName,
            members,
          }, result => {
            this.projectTeamLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectTeamEdit = false;
              this.showProjectReview = true;
              this.$refs.ptBlockToggle.inactive();
              this.$refs.projectTeam.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })

        }
      });
    },
    //项目评审编辑操作相关方法
    projectReviewEditClick(){
      this.inactiveAll("prBlockToggle");
      this.projectReviewEdit = true;
    },
    projectReviewMouseleaveHandle({showBtn}){
      this.projectReviewEdit = showBtn;
    },
    projectReviewCancelClick(){
      this.projectReviewEdit = false
      this.$refs.projectReview.clearValidate();
      this.projectReview = this.undertakeDetail.projectReview ? JSON.parse(JSON.stringify(this.undertakeDetail.projectReview)) : {}
    },
    projectReviewSaveClick(){
      if(this.projectReview.reviewNeed==1){
        this.projectReview.members = COMMON.changePersonSelectData(this.$refs.projectReviewMembers);
        this.$set(this.projectReview,'projectReviewMembersStr',COMMON.arrToStr(this.projectReview.members,"peopleName"))
      }
      this.$refs.projectReview.validate((valid, error) => {
        if (valid) {
          this.projectReviewLoading = true;
          const {
            reviewNeed,
            reviewDate,
            reviewAdress,
            reviewComments,
            reviewCommentsNote,
            reviewDataFileid,
            meetingMinutes,
            members
          } = this.projectReview;
          let params = reviewNeed == 0 ? {
            reviewNeed,
          }:{
            reviewNeed,
            reviewDate,
            reviewAdress,
            reviewComments,
            reviewCommentsNote,
            reviewDataFileid,
            meetingMinutes,
            members
          };
          opr_management.saveProjectUndertakeReview(Object.assign({},{
            projectid:this.$router.history.current.params.id,
          },params), result => {
            this.projectReviewLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectReviewEdit = false;
              this.showProjectWbs = true;
              this.$refs.prBlockToggle.inactive();
              this.$refs.projectReview.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })
        }

      })

    },

    //承揽阶段WBS及预算申请 编辑操作相关方法
    projectWbsEditClick(){
      this.inactiveAll("wbsBlockToggle");
      this.projectWbsEdit = true;
    },
    projectWbsMouseleaveHandle({showBtn}){
      this.projectWbsEdit = showBtn;
    },
    projectWbsCancelClick(){
      this.projectWbsEdit = false
      this.$refs.projectWbs.clearValidate();
      this.projectWbs = this.undertakeDetail.projectWbs ? JSON.parse(JSON.stringify(this.undertakeDetail.projectWbs)) : {}
    },
    projectWbsSaveClick(){
      if(this.projectWbs.cbsNeed==1){
        this.$set(this.projectWbs,"leadingmanName",COMMON.changePersonSelectData(this.$refs.projectWbsLeadingman,false).peopleName)
        this.$set(this.projectWbs,"leadingman",COMMON.changePersonSelectData(this.$refs.projectWbsLeadingman,false).peopleNumber)
      }
      this.$refs.projectWbs.validate((valid, error) => {
        if (valid) {
          this.projectWbsLoading = true;
          const {
            cbsNeed,
            cbsCode,
            cbsName,
            leadingman,
            leadingmanName,
            budgetType,
            currency,
            depositAmount,
            payStorage,
            transClassification,
            wbssqFileid,
            yssqFileid,
          } = this.projectWbs;
          let params = cbsNeed == 0 ? {
            cbsNeed,
          } :{
            cbsNeed,
            cbsCode,
            cbsName,
            leadingman,
            leadingmanName,
            budgetType,
            currency,
            depositAmount,
            payStorage,
            transClassification,
            wbssqFileid,
            yssqFileid,
          }
          opr_management.saveProjectUndertakeWbs(Object.assign({},{
            projectid:this.$router.history.current.params.id,
          },params), result => {
            this.projectWbsLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectWbsEdit = false;
              this.$refs.wbsBlockToggle.inactive();
              this.$refs.projectWbs.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })
        }

      })

    },

    //主任室决策 编辑操作相关方法
    projectDirectorMakingEditClick(){
      this.inactiveAll("pdmBlockToggle");
      this.projectDirectorMakingEdit = true;
    },
    projectDirectorMakingMouseleaveHandle({showBtn}){
      this.projectDirectorMakingEdit = showBtn;
    },
    projectDirectorMakingCancelClick(){
      this.projectDirectorMakingEdit = false
      this.$refs.projectDirectorMaking.clearValidate();
      this.projectDirectorMaking = this.undertakeDetail.projectDirectorMaking ? JSON.parse(JSON.stringify(this.undertakeDetail.projectDirectorMaking))  : {}
    },
    projectDirectorMakingSaveClick(){
      this.$refs.projectDirectorMaking.validate((valid, error) => {
        if (valid) {
          this.projectDirectorMakingLoading = true;
          const {
            directorMakeNeed,
            reviewDate,
            reviewAdress,
            reviewComments,
            reviewCommentsNote,
            reportDataFileid,
            decisionmakingMeetingFileid,
            wchldFileid,
            jtjcjlFileid,
            jtjchyjyFileid,
            signFileid,
          } = this.projectDirectorMaking;
          let params = directorMakeNeed == 0 ? {
            directorMakeNeed,
          } :{
            directorMakeNeed,
            reviewDate,
            reviewAdress,
            reviewComments,
            reviewCommentsNote,
            reportDataFileid,
            decisionmakingMeetingFileid,
            wchldFileid,
            jtjcjlFileid,
            jtjchyjyFileid,
            signFileid,
          }
          opr_management.saveProjectUndertakeDirectorMaking(Object.assign({},{
            projectid:this.$router.history.current.params.id,
          },params), result => {
            this.projectDirectorMakingLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectDirectorMakingEdit = false;
              this.$refs.pdmBlockToggle.inactive();
              this.$refs.projectDirectorMaking.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })
        }

      })

    },

    //投标报价 编辑操作相关方法
    projectTenderOfferEditClick(){
      this.inactiveAll("toBlockToggle");
      this.projectTenderOfferEdit = true;
    },
    projectTenderOfferMouseleaveHandle({showBtn}){
      this.projectTenderOfferEdit = showBtn;
    },
    projectTenderOfferCancelClick(){
      this.projectTenderOfferEdit = false
      this.$refs.projectTenderOffer.clearValidate();
      this.projectTenderOffer = this.undertakeDetail.projectTenderOffer ? JSON.parse(JSON.stringify(this.undertakeDetail.projectTenderOffer)) : {}
    },
    projectTenderOfferSaveClick(){
      this.$refs.projectTenderOffer.validate((valid, error) => {
        if (valid) {
          this.projectTenderOfferLoading = true;
          const {
            bjNeed,
            bjsFileid,
            sycsbFileid	,
          } = this.projectTenderOffer;
          let params = bjNeed == 0 ? {
            bjNeed,
          } :{
            bjNeed,
            bjsFileid,
            sycsbFileid	,
          }
          opr_management.saveProjectUndertakeTenderOffer(Object.assign({},{
            projectid:this.$router.history.current.params.id,
          },params), result => {
            this.projectTenderOfferLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectTenderOfferEdit = false;
              this.showProjectTenderOffer = true; 
              this.$refs.toBlockToggle.inactive();
              this.$refs.projectTenderOffer.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })
        }

      })

    },

    //合同推荐 编辑操作相关方法
    projectHtEditClick(){
      this.inactiveAll("htBlockToggle");
      this.projectHtEdit = true;
    },
    projectHtMouseleaveHandle({showBtn}){
      this.projectHtEdit = showBtn;
    },
    projectHtCancelClick(){
      this.projectHtEdit = false
      this.$refs.projectHt.clearValidate();
      this.projectHt = this.undertakeDetail.projectHt ? JSON.parse(JSON.stringify(this.undertakeDetail.projectHt)) : {}
    },
    projectHtSaveClick(){
      this.$refs.projectHt.validate((valid, error) => {
        if (valid) {
          this.projectHtLoading = true;
          const {
            contractCode,
            contractName,
            iszuidaguanlian,
            contractQjdb,
            contractCsjg,
            hdTypeChild,
            hdType,
            contractFileid,
          } = this.projectHt;
          let params = {
            contractCode,
            contractName,
            iszuidaguanlian,
            contractQjdb,
            contractCsjg,
            hdTypeChild,
            hdType,
            contractFileid,
          }
          opr_management.saveProjectUndertakeHt(Object.assign({},{
            projectid:this.$router.history.current.params.id,
          },params), result => {
            this.projectHtLoading = false;
            if (result.code === Constant.RT_SUCCESS) {
              this.projectHtEdit = false;
              this.$refs.htBlockToggle.inactive();
              this.$refs.projectHt.clearValidate();
              this.getInitData();
            } else {
              ALERT.error(result.msg)
            }
            
          })
        }

      })

    },

    

  },
}
</script>

<style lang="scss">
.undertake-detail{
  .el-form-item__content>span:empty:before{
    content:"--"
  }
  .form-input{
    width: 80% !important;
  }
  .double-select{
    padding-right: 150px;
    .el-select.el-select{
      width: 35.3% !important;
      .el-input{
        width: 100% !important;
      }
    }

  }
}
</style>
